#pragma once
#include "CoreDll.h"
#include <cmath>

class Vector3
{
public:
	Real x,y,z;
public:
	Vector3::Vector3(void):x(0.f),y(0.f),z(0.f)
	{
	}

	Vector3(Real x,Real y,Real z):x(x),y(y),z(z){}

	Vector3::~Vector3(void)
	{
	}

	Vector3 operator + (const Vector3 & vec3) const{
		return Vector3(x+vec3.x,y+vec3.y,z+vec3.z);
	}

	Vector3 operator - (const Vector3 & vec3) const{
		return Vector3(x-vec3.x,y-vec3.y,z-vec3.z);
	}

	Vector3 & operator += (const Vector3& vec3){
		x+=vec3.x;
		y+=vec3.y;
		z+=vec3.z;
		return *this;
	}

	Vector3 & operator -= (const Vector3 & vec3){
		x-=vec3.x;
		y-=vec3.y;
		z-=vec3.z;
		return *this;
	}

	Vector3 operator * (const Vector3 & vec3) const{
		return Vector3(x*vec3.x,y*vec3.y,z*vec3.z);
	}

	Vector3 & operator *= (const Vector3 & vec3){
		x*=vec3.x;
		y*=vec3.y;
		z*=vec3.z;
		return *this;
	}

	Vector3 operator * (Real a) const{
		return Vector3(x*a,y*a,z*a);
	}

	Vector3 operator / (Real a) const{
		return Vector3(x/a,y/a,z/a);
	}

	Vector3 & operator *= (Real a){
		x *= a;
		y *= a;
		z *= a;
		return *this;
	}

	Vector3 & operator /= (Real a){
		x /= a;
		y /= a;
		z /= a;
		return *this;
	}

	Real lengthSq() const{
		return x*x + y*y + z*z;
	}

	Real length() const{
		return sqrt(x*x + y*y + z*z);
	}

	void normalize(){
		Real len = length();
		this->operator /=(len);
	}

	Vector3 getNormalize() const{
		Vector3 vec3(*this);
		vec3.normalize();
		return vec3;
	}

	Vector3 crossProduct(const Vector3& vec3) const{
		return Vector3(y * vec3.z - z * vec3.y ,z * vec3.x - x * vec3.z , x * vec3.y - y * vec3.x);
	}

	Vector3 dotProduct(const Vector3& vec3) const{
		return Vector3(x*vec3.x,y*vec3.y,z*vec3.z);
	}
public:
	static const Vector3 Zero;
	static const Vector3 Identity;
	static const Vector3 UnitX;
	static const Vector3 UnitY;
	static const Vector3 UnitZ;
	static const Vector3 NegativeUnitX;
	static const Vector3 NegativeUnitY;
	static const Vector3 NegativeUnitZ;
};
